class Solution:
    def checkInclusion(self, s1: str, s2: str) -> bool:
        mapper1={}
        for i in s1:
            if i in mapper1:
                mapper1[i]+=1
            else:
                mapper1[i]=1
        len1=len(s1)
        mapper2={}
        count=0
        left=right=0
        def equal(m1,m2):
            for i in m1.keys():
                if m1[i]!=m2[i]:
                    return False
            return True
        while right<len(s2):
            if s2[right] not in mapper1:
                mapper2={}
                right+=1
                left=right
            else:
                if s2[right] in mapper2:
                    mapper2[s2[right]]+=1
                else:
                    mapper2[s2[right]]=1
                if mapper2[s2[right]]>mapper1[s2[right]]:
                    while mapper2[s2[right]]>mapper1[s2[right]]:
                        mapper2[s2[left]]-=1
                        left+=1
                right+=1
                if right-left==len1 and equal(mapper1,mapper2):
                    return True
        return False

'''
执行用时：
68 ms
, 在所有 Python3 提交中击败了
92.13%
的用户
内存消耗：
15 MB
, 在所有 Python3 提交中击败了
24.30%
的用户
'''